<?php


/**
 * Base class that represents a query for the 'reservation' table.
 *
 * 
 *
 * @method     ReservationQuery orderByResid($order = Criteria::ASC) Order by the resid column
 * @method     ReservationQuery orderByCustomerid($order = Criteria::ASC) Order by the customerid column
 * @method     ReservationQuery orderByPickup($order = Criteria::ASC) Order by the pickup column
 * @method     ReservationQuery orderByDropoff($order = Criteria::ASC) Order by the dropoff column
 * @method     ReservationQuery orderByCatname($order = Criteria::ASC) Order by the catname column
 * @method     ReservationQuery orderByStarts($order = Criteria::ASC) Order by the starts column
 * @method     ReservationQuery orderByEnds($order = Criteria::ASC) Order by the ends column
 * @method     ReservationQuery orderByPlaced($order = Criteria::ASC) Order by the placed column
 * @method     ReservationQuery orderByPrice($order = Criteria::ASC) Order by the price column
 *
 * @method     ReservationQuery groupByResid() Group by the resid column
 * @method     ReservationQuery groupByCustomerid() Group by the customerid column
 * @method     ReservationQuery groupByPickup() Group by the pickup column
 * @method     ReservationQuery groupByDropoff() Group by the dropoff column
 * @method     ReservationQuery groupByCatname() Group by the catname column
 * @method     ReservationQuery groupByStarts() Group by the starts column
 * @method     ReservationQuery groupByEnds() Group by the ends column
 * @method     ReservationQuery groupByPlaced() Group by the placed column
 * @method     ReservationQuery groupByPrice() Group by the price column
 *
 * @method     ReservationQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method     ReservationQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method     ReservationQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method     ReservationQuery leftJoinCustomer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Customer relation
 * @method     ReservationQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation
 * @method     ReservationQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation
 *
 * @method     ReservationQuery leftJoinStationRelatedByPickup($relationAlias = null) Adds a LEFT JOIN clause to the query using the StationRelatedByPickup relation
 * @method     ReservationQuery rightJoinStationRelatedByPickup($relationAlias = null) Adds a RIGHT JOIN clause to the query using the StationRelatedByPickup relation
 * @method     ReservationQuery innerJoinStationRelatedByPickup($relationAlias = null) Adds a INNER JOIN clause to the query using the StationRelatedByPickup relation
 *
 * @method     ReservationQuery leftJoinStationRelatedByDropoff($relationAlias = null) Adds a LEFT JOIN clause to the query using the StationRelatedByDropoff relation
 * @method     ReservationQuery rightJoinStationRelatedByDropoff($relationAlias = null) Adds a RIGHT JOIN clause to the query using the StationRelatedByDropoff relation
 * @method     ReservationQuery innerJoinStationRelatedByDropoff($relationAlias = null) Adds a INNER JOIN clause to the query using the StationRelatedByDropoff relation
 *
 * @method     ReservationQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation
 * @method     ReservationQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
 * @method     ReservationQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation
 *
 * @method     Reservation findOne(PropelPDO $con = null) Return the first Reservation matching the query
 * @method     Reservation findOneOrCreate(PropelPDO $con = null) Return the first Reservation matching the query, or a new Reservation object populated from the query conditions when no match is found
 *
 * @method     Reservation findOneByResid(int $resid) Return the first Reservation filtered by the resid column
 * @method     Reservation findOneByCustomerid(int $customerid) Return the first Reservation filtered by the customerid column
 * @method     Reservation findOneByPickup(int $pickup) Return the first Reservation filtered by the pickup column
 * @method     Reservation findOneByDropoff(int $dropoff) Return the first Reservation filtered by the dropoff column
 * @method     Reservation findOneByCatname(string $catname) Return the first Reservation filtered by the catname column
 * @method     Reservation findOneByStarts(string $starts) Return the first Reservation filtered by the starts column
 * @method     Reservation findOneByEnds(string $ends) Return the first Reservation filtered by the ends column
 * @method     Reservation findOneByPlaced(string $placed) Return the first Reservation filtered by the placed column
 * @method     Reservation findOneByPrice(string $price) Return the first Reservation filtered by the price column
 *
 * @method     array findByResid(int $resid) Return Reservation objects filtered by the resid column
 * @method     array findByCustomerid(int $customerid) Return Reservation objects filtered by the customerid column
 * @method     array findByPickup(int $pickup) Return Reservation objects filtered by the pickup column
 * @method     array findByDropoff(int $dropoff) Return Reservation objects filtered by the dropoff column
 * @method     array findByCatname(string $catname) Return Reservation objects filtered by the catname column
 * @method     array findByStarts(string $starts) Return Reservation objects filtered by the starts column
 * @method     array findByEnds(string $ends) Return Reservation objects filtered by the ends column
 * @method     array findByPlaced(string $placed) Return Reservation objects filtered by the placed column
 * @method     array findByPrice(string $price) Return Reservation objects filtered by the price column
 *
 * @package    propel.generator.ise-php.om
 */
abstract class BaseReservationQuery extends ModelCriteria
{
	
	/**
	 * Initializes internal state of BaseReservationQuery object.
	 *
	 * @param     string $dbName The dabase name
	 * @param     string $modelName The phpName of a model, e.g. 'Book'
	 * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
	 */
	public function __construct($dbName = 'ise-php', $modelName = 'Reservation', $modelAlias = null)
	{
		parent::__construct($dbName, $modelName, $modelAlias);
	}

	/**
	 * Returns a new ReservationQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    ReservationQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof ReservationQuery) {
			return $criteria;
		}
		$query = new ReservationQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}

	/**
	 * Find object by primary key.
	 * Propel uses the instance pool to skip the database if the object exists.
	 * Go fast if the query is untouched.
	 *
	 * <code>
	 * $obj  = $c->findPk(12, $con);
	 * </code>
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    Reservation|array|mixed the result, formatted by the current formatter
	 */
	public function findPk($key, $con = null)
	{
		if ($key === null) {
			return null;
		}
		if ((null !== ($obj = ReservationPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
			// the object is alredy in the instance pool
			return $obj;
		}
		if ($con === null) {
			$con = Propel::getConnection(ReservationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}
		$this->basePreSelect($con);
		if ($this->formatter || $this->modelAlias || $this->with || $this->select
		 || $this->selectColumns || $this->asColumns || $this->selectModifiers
		 || $this->map || $this->having || $this->joins) {
			return $this->findPkComplex($key, $con);
		} else {
			return $this->findPkSimple($key, $con);
		}
	}

	/**
	 * Find object by primary key using raw SQL to go fast.
	 * Bypass doSelect() and the object formatter by using generated code.
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con A connection object
	 *
	 * @return    Reservation A model object, or null if the key is not found
	 */
	protected function findPkSimple($key, $con)
	{
		$sql = 'SELECT `RESID`, `CUSTOMERID`, `PICKUP`, `DROPOFF`, `CATNAME`, `STARTS`, `ENDS`, `PLACED`, `PRICE` FROM `reservation` WHERE `RESID` = :p0';
		try {
			$stmt = $con->prepare($sql);			
			$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
			$stmt->execute();
		} catch (Exception $e) {
			Propel::log($e->getMessage(), Propel::LOG_ERR);
			throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
		}
		$obj = null;
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$obj = new Reservation();
			$obj->hydrate($row);
			ReservationPeer::addInstanceToPool($obj, (string) $key);
		}
		$stmt->closeCursor();

		return $obj;
	}

	/**
	 * Find object by primary key.
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con A connection object
	 *
	 * @return    Reservation|array|mixed the result, formatted by the current formatter
	 */
	protected function findPkComplex($key, $con)
	{
		// As the query uses a PK condition, no limit(1) is necessary.
		$criteria = $this->isKeepQuery() ? clone $this : $this;
		$stmt = $criteria
			->filterByPrimaryKey($key)
			->doSelect($con);
		return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
	}

	/**
	 * Find objects by primary key
	 * <code>
	 * $objs = $c->findPks(array(12, 56, 832), $con);
	 * </code>
	 * @param     array $keys Primary keys to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
	 */
	public function findPks($keys, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
		}
		$this->basePreSelect($con);
		$criteria = $this->isKeepQuery() ? clone $this : $this;
		$stmt = $criteria
			->filterByPrimaryKeys($keys)
			->doSelect($con);
		return $criteria->getFormatter()->init($criteria)->format($stmt);
	}

	/**
	 * Filter the query by primary key
	 *
	 * @param     mixed $key Primary key to use for the query
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKey($key)
	{
		return $this->addUsingAlias(ReservationPeer::RESID, $key, Criteria::EQUAL);
	}

	/**
	 * Filter the query by a list of primary keys
	 *
	 * @param     array $keys The list of primary key to use for the query
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKeys($keys)
	{
		return $this->addUsingAlias(ReservationPeer::RESID, $keys, Criteria::IN);
	}

	/**
	 * Filter the query on the resid column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByResid(1234); // WHERE resid = 1234
	 * $query->filterByResid(array(12, 34)); // WHERE resid IN (12, 34)
	 * $query->filterByResid(array('min' => 12)); // WHERE resid > 12
	 * </code>
	 *
	 * @param     mixed $resid The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByResid($resid = null, $comparison = null)
	{
		if (is_array($resid) && null === $comparison) {
			$comparison = Criteria::IN;
		}
		return $this->addUsingAlias(ReservationPeer::RESID, $resid, $comparison);
	}

	/**
	 * Filter the query on the customerid column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByCustomerid(1234); // WHERE customerid = 1234
	 * $query->filterByCustomerid(array(12, 34)); // WHERE customerid IN (12, 34)
	 * $query->filterByCustomerid(array('min' => 12)); // WHERE customerid > 12
	 * </code>
	 *
	 * @see       filterByCustomer()
	 *
	 * @param     mixed $customerid The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByCustomerid($customerid = null, $comparison = null)
	{
		if (is_array($customerid)) {
			$useMinMax = false;
			if (isset($customerid['min'])) {
				$this->addUsingAlias(ReservationPeer::CUSTOMERID, $customerid['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($customerid['max'])) {
				$this->addUsingAlias(ReservationPeer::CUSTOMERID, $customerid['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ReservationPeer::CUSTOMERID, $customerid, $comparison);
	}

	/**
	 * Filter the query on the pickup column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByPickup(1234); // WHERE pickup = 1234
	 * $query->filterByPickup(array(12, 34)); // WHERE pickup IN (12, 34)
	 * $query->filterByPickup(array('min' => 12)); // WHERE pickup > 12
	 * </code>
	 *
	 * @see       filterByStationRelatedByPickup()
	 *
	 * @param     mixed $pickup The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByPickup($pickup = null, $comparison = null)
	{
		if (is_array($pickup)) {
			$useMinMax = false;
			if (isset($pickup['min'])) {
				$this->addUsingAlias(ReservationPeer::PICKUP, $pickup['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($pickup['max'])) {
				$this->addUsingAlias(ReservationPeer::PICKUP, $pickup['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ReservationPeer::PICKUP, $pickup, $comparison);
	}

	/**
	 * Filter the query on the dropoff column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByDropoff(1234); // WHERE dropoff = 1234
	 * $query->filterByDropoff(array(12, 34)); // WHERE dropoff IN (12, 34)
	 * $query->filterByDropoff(array('min' => 12)); // WHERE dropoff > 12
	 * </code>
	 *
	 * @see       filterByStationRelatedByDropoff()
	 *
	 * @param     mixed $dropoff The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByDropoff($dropoff = null, $comparison = null)
	{
		if (is_array($dropoff)) {
			$useMinMax = false;
			if (isset($dropoff['min'])) {
				$this->addUsingAlias(ReservationPeer::DROPOFF, $dropoff['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($dropoff['max'])) {
				$this->addUsingAlias(ReservationPeer::DROPOFF, $dropoff['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ReservationPeer::DROPOFF, $dropoff, $comparison);
	}

	/**
	 * Filter the query on the catname column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByCatname('fooValue');   // WHERE catname = 'fooValue'
	 * $query->filterByCatname('%fooValue%'); // WHERE catname LIKE '%fooValue%'
	 * </code>
	 *
	 * @param     string $catname The value to use as filter.
	 *              Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByCatname($catname = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($catname)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $catname)) {
				$catname = str_replace('*', '%', $catname);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(ReservationPeer::CATNAME, $catname, $comparison);
	}

	/**
	 * Filter the query on the starts column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByStarts('2011-03-14'); // WHERE starts = '2011-03-14'
	 * $query->filterByStarts('now'); // WHERE starts = '2011-03-14'
	 * $query->filterByStarts(array('max' => 'yesterday')); // WHERE starts > '2011-03-13'
	 * </code>
	 *
	 * @param     mixed $starts The value to use as filter.
	 *              Values can be integers (unix timestamps), DateTime objects, or strings.
	 *              Empty strings are treated as NULL.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByStarts($starts = null, $comparison = null)
	{
		if (is_array($starts)) {
			$useMinMax = false;
			if (isset($starts['min'])) {
				$this->addUsingAlias(ReservationPeer::STARTS, $starts['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($starts['max'])) {
				$this->addUsingAlias(ReservationPeer::STARTS, $starts['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ReservationPeer::STARTS, $starts, $comparison);
	}

	/**
	 * Filter the query on the ends column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByEnds('2011-03-14'); // WHERE ends = '2011-03-14'
	 * $query->filterByEnds('now'); // WHERE ends = '2011-03-14'
	 * $query->filterByEnds(array('max' => 'yesterday')); // WHERE ends > '2011-03-13'
	 * </code>
	 *
	 * @param     mixed $ends The value to use as filter.
	 *              Values can be integers (unix timestamps), DateTime objects, or strings.
	 *              Empty strings are treated as NULL.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByEnds($ends = null, $comparison = null)
	{
		if (is_array($ends)) {
			$useMinMax = false;
			if (isset($ends['min'])) {
				$this->addUsingAlias(ReservationPeer::ENDS, $ends['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($ends['max'])) {
				$this->addUsingAlias(ReservationPeer::ENDS, $ends['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ReservationPeer::ENDS, $ends, $comparison);
	}

	/**
	 * Filter the query on the placed column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByPlaced('2011-03-14'); // WHERE placed = '2011-03-14'
	 * $query->filterByPlaced('now'); // WHERE placed = '2011-03-14'
	 * $query->filterByPlaced(array('max' => 'yesterday')); // WHERE placed > '2011-03-13'
	 * </code>
	 *
	 * @param     mixed $placed The value to use as filter.
	 *              Values can be integers (unix timestamps), DateTime objects, or strings.
	 *              Empty strings are treated as NULL.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByPlaced($placed = null, $comparison = null)
	{
		if (is_array($placed)) {
			$useMinMax = false;
			if (isset($placed['min'])) {
				$this->addUsingAlias(ReservationPeer::PLACED, $placed['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($placed['max'])) {
				$this->addUsingAlias(ReservationPeer::PLACED, $placed['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ReservationPeer::PLACED, $placed, $comparison);
	}

	/**
	 * Filter the query on the price column
	 *
	 * Example usage:
	 * <code>
	 * $query->filterByPrice(1234); // WHERE price = 1234
	 * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
	 * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
	 * </code>
	 *
	 * @param     mixed $price The value to use as filter.
	 *              Use scalar values for equality.
	 *              Use array values for in_array() equivalent.
	 *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByPrice($price = null, $comparison = null)
	{
		if (is_array($price)) {
			$useMinMax = false;
			if (isset($price['min'])) {
				$this->addUsingAlias(ReservationPeer::PRICE, $price['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($price['max'])) {
				$this->addUsingAlias(ReservationPeer::PRICE, $price['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(ReservationPeer::PRICE, $price, $comparison);
	}

	/**
	 * Filter the query by a related Customer object
	 *
	 * @param     Customer|PropelCollection $customer The related object(s) to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByCustomer($customer, $comparison = null)
	{
		if ($customer instanceof Customer) {
			return $this
				->addUsingAlias(ReservationPeer::CUSTOMERID, $customer->getPersonid(), $comparison);
		} elseif ($customer instanceof PropelCollection) {
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
			return $this
				->addUsingAlias(ReservationPeer::CUSTOMERID, $customer->toKeyValue('PrimaryKey', 'Personid'), $comparison);
		} else {
			throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the Customer relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Customer');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Customer');
		}

		return $this;
	}

	/**
	 * Use the Customer relation Customer object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CustomerQuery A secondary query class using the current class as primary query
	 */
	public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinCustomer($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Customer', 'CustomerQuery');
	}

	/**
	 * Filter the query by a related Station object
	 *
	 * @param     Station|PropelCollection $station The related object(s) to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByStationRelatedByPickup($station, $comparison = null)
	{
		if ($station instanceof Station) {
			return $this
				->addUsingAlias(ReservationPeer::PICKUP, $station->getStationid(), $comparison);
		} elseif ($station instanceof PropelCollection) {
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
			return $this
				->addUsingAlias(ReservationPeer::PICKUP, $station->toKeyValue('PrimaryKey', 'Stationid'), $comparison);
		} else {
			throw new PropelException('filterByStationRelatedByPickup() only accepts arguments of type Station or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the StationRelatedByPickup relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function joinStationRelatedByPickup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('StationRelatedByPickup');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'StationRelatedByPickup');
		}

		return $this;
	}

	/**
	 * Use the StationRelatedByPickup relation Station object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    StationQuery A secondary query class using the current class as primary query
	 */
	public function useStationRelatedByPickupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinStationRelatedByPickup($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'StationRelatedByPickup', 'StationQuery');
	}

	/**
	 * Filter the query by a related Station object
	 *
	 * @param     Station|PropelCollection $station The related object(s) to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByStationRelatedByDropoff($station, $comparison = null)
	{
		if ($station instanceof Station) {
			return $this
				->addUsingAlias(ReservationPeer::DROPOFF, $station->getStationid(), $comparison);
		} elseif ($station instanceof PropelCollection) {
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
			return $this
				->addUsingAlias(ReservationPeer::DROPOFF, $station->toKeyValue('PrimaryKey', 'Stationid'), $comparison);
		} else {
			throw new PropelException('filterByStationRelatedByDropoff() only accepts arguments of type Station or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the StationRelatedByDropoff relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function joinStationRelatedByDropoff($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('StationRelatedByDropoff');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'StationRelatedByDropoff');
		}

		return $this;
	}

	/**
	 * Use the StationRelatedByDropoff relation Station object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    StationQuery A secondary query class using the current class as primary query
	 */
	public function useStationRelatedByDropoffQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinStationRelatedByDropoff($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'StationRelatedByDropoff', 'StationQuery');
	}

	/**
	 * Filter the query by a related Category object
	 *
	 * @param     Category|PropelCollection $category The related object(s) to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function filterByCategory($category, $comparison = null)
	{
		if ($category instanceof Category) {
			return $this
				->addUsingAlias(ReservationPeer::CATNAME, $category->getCatname(), $comparison);
		} elseif ($category instanceof PropelCollection) {
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
			return $this
				->addUsingAlias(ReservationPeer::CATNAME, $category->toKeyValue('PrimaryKey', 'Catname'), $comparison);
		} else {
			throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection');
		}
	}

	/**
	 * Adds a JOIN clause to the query using the Category relation
	 *
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Category');

		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}

		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Category');
		}

		return $this;
	}

	/**
	 * Use the Category relation Category object
	 *
	 * @see       useQuery()
	 *
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    CategoryQuery A secondary query class using the current class as primary query
	 */
	public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinCategory($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Category', 'CategoryQuery');
	}

	/**
	 * Exclude object from result
	 *
	 * @param     Reservation $reservation Object to remove from the list of results
	 *
	 * @return    ReservationQuery The current query, for fluid interface
	 */
	public function prune($reservation = null)
	{
		if ($reservation) {
			$this->addUsingAlias(ReservationPeer::RESID, $reservation->getResid(), Criteria::NOT_EQUAL);
		}

		return $this;
	}

} // BaseReservationQuery